package com.goods.business.converter;

import com.goods.common.model.business.Supplier;
import com.goods.common.vo.business.SupplierVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;


/**********************
 *
 *@Author 闫星忠
 *@Time 2021/12/15  23:08
 *
 */
public class SupplierConverter {


    /**
     * 转vo
     * @return
     */
    public static SupplierVO converterToSupplierVO(Supplier supplier){
        SupplierVO supplierVO = new SupplierVO();
        BeanUtils.copyProperties(supplier,supplierVO);
        return supplierVO;
    }


    public static List<SupplierVO> converterToSupplierVOList(List<Supplier> suppliers){
        List<SupplierVO> supplierVOS = new ArrayList<>();
        if (!CollectionUtils.isEmpty(suppliers)){
            for (Supplier supplier : suppliers){
                SupplierVO supplierVO = new SupplierVO();
                BeanUtils.copyProperties(supplier,supplierVO);
                supplierVOS.add(supplierVO);
            }
        }

        return supplierVOS;
    }
}
